package com.fstec.ks.master.netty;

import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;

import com.sinotn.ks.definition.MessageSendCallback;

@SuppressWarnings("rawtypes")
public class WrapperListener implements GenericFutureListener {
	private MessageSendCallback msc;

	public WrapperListener(MessageSendCallback msc){
		this.msc=msc;
	}

	@Override
	public void operationComplete(Future future) throws Exception {
		if(future.isSuccess()){
			msc.onSuccess();
		}else if(future.isCancelled()){
			msc.onCancel();
		}else if(future.cause()!=null){
			Throwable e=future.cause();
			msc.onFailure(e);
		}
	}
}
